import { RoleAttributeType } from "../../../../role/model/RoleEnum";
import { Role } from "../../../../role/Role";
import { ISkillReport } from "../../model/report/ISkillReport";
import { RoleDamageNormal } from "./RoleDamageNormal";

/** 角色技能攻击伤害计算 */
export class RoleDamageSkill {
    //技能伤害 = 我普通攻击伤害 * 技能倍率 *（1 + 我技能伤害 - 敌技能减伤）;
    static getDamage(isr: ISkillReport, target: Role) {
        if(isr.caster){
            var caster = isr.caster;
            var normalDamage = RoleDamageNormal.getDamage(isr, target); //我普通攻击伤害
            var skillRatio = isr.skill.SkillModel.skillRatio;           //技能倍率
            var jnsh = caster.getNumericValue(RoleAttributeType.jnsh);  //我技能伤害
            var jnjs = target.getNumericValue(RoleAttributeType.jnjs);  //敌技能减伤
            var finalDamage = normalDamage * skillRatio * (1 + jnsh - jnjs);

            return Math.max(Math.round(finalDamage), 0);
        }else{
            return 0;
        }
    }
}